package com.lzw.service.impl.superAdmin;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lzw.mapper.superAdmin.SupplierReturnsManageMapper;
import com.lzw.pojo.SupplierReturns;
import com.lzw.service.superAdmin.SupplierReturnsManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class SupplierReturnsManageServiceImpl implements SupplierReturnsManageService {

    @Autowired
    private SupplierReturnsManageMapper supplierReturnsManageMapper;

    @Override
    public List<SupplierReturns> list(Integer pageNum, Integer pageSize, String supplier, String medicine, LocalDate returnDate) {
        PageHelper.startPage(pageNum,pageSize);
        List<SupplierReturns> list = supplierReturnsManageMapper.list(supplier, medicine, returnDate);
        Page<SupplierReturns> supplierReturns = (Page<SupplierReturns>) list;
        return supplierReturns;
    }

    @Override
    public void delete(List<Integer> ids) {
        supplierReturnsManageMapper.delete(ids);
    }

    @Override
    public void add(SupplierReturns supplierReturns) {
        supplierReturns.setReturnDate(LocalDate.now());
        supplierReturnsManageMapper.add(supplierReturns);
    }

    @Override
    public void update(SupplierReturns supplierReturns) {
        supplierReturnsManageMapper.update(supplierReturns);
    }
}
